clear all

*set working directory
use "data_validation.dta", replace

label var accept_1 "Accept - Kill"
label var accept_2 "Accept - Hit with car"
label var accept_3 "Accept - Throw rocks"
label var accept_4 "Accept - Punch face"
label var accept_5 "Accept - Spray mace"
label var accept_6 "Accept - Throw brick"
label var accept_7 "Accept - Throw eggs"
label var accept_8 "Accept - Protest with weapons"
label var accept_9 "Accept - Curse in face"
label var accept_10 "Accept - Send threats"
label var accept_11 "Accept - Share address"
label var accept_12 "Accept - Share location"
label var accept_13 "Accept - Shout out"
label var accept_14 "Accept - Block street"
label var accept_15 "Accept - Heckle event"
label var accept_16 "Accept - Write letter"
label var accept_17 "Accept - Call office"
label var accept_18 "Accept - Write news"
label var accept_19 "Accept - Donate money"
label var accept_20 "Accept - Signs supporting"
label var accept_21 "Accept - Signs opposing"
label var accept_22 "Accept - Campaign"

label var harm_1 "Harm - Kill"
label var harm_2 "Harm - Hit with car"
label var harm_3 "Harm - Throw rocks"
label var harm_4 "Harm - Punch face"
label var harm_5 "Harm - Spray mace"
label var harm_6 "Harm - Throw brick"
label var harm_7 "Harm - Throw eggs"
label var harm_8 "Harm - Protest with weapons"
label var harm_9 "Harm - Curse in face"
label var harm_10 "Harm - Send threats"
label var harm_11 "Harm - Share address"
label var harm_12 "Harm - Share location"
label var harm_13 "Harm - Shout out"
label var harm_14 "Harm - Block street"
label var harm_15 "Harm - Heckle event"
label var harm_16 "Harm - Write letter"
label var harm_17 "Harm - Call office"
label var harm_18 "Harm - Write news"
label var harm_19 "Harm - Donate money"
label var harm_20 "Harm - Signs supporting"
label var harm_21 "Harm - Signs opposing"
label var harm_22 "Harm - Campaign"

label var fear_1 "Fear - Kill"
label var fear_2 "Fear - Hit with car"
label var fear_3 "Fear - Throw rocks"
label var fear_4 "Fear - Punch face"
label var fear_5 "Fear - Spray mace"
label var fear_6 "Fear - Throw brick"
label var fear_7 "Fear - Throw eggs"
label var fear_8 "Fear - Protest with weapons"
label var fear_9 "Fear - Curse in face"
label var fear_10 "Fear - Send threats"
label var fear_11 "Fear - Share address"
label var fear_12 "Fear - Share location"
label var fear_13 "Fear - Shout out"
label var fear_14 "Fear - Block street"
label var fear_15 "Fear - Heckle event"
label var fear_16 "Fear - Write letter"
label var fear_17 "Fear - Call office"
label var fear_18 "Fear - Write news"
label var fear_19 "Fear - Donate money"
label var fear_20 "Fear - Signs supporting"
label var fear_21 "Fear - Signs opposing"
label var fear_22 "Fear - Campaign"

label var belief_1 "Belief - Kill"
label var belief_2 "Belief - Hit with car"
label var belief_3 "Belief - Throw rocks"
label var belief_4 "Belief - Punch face"
label var belief_5 "Belief - Spray mace"
label var belief_6 "Belief - Throw brick"
label var belief_7 "Belief - Throw eggs"
label var belief_8 "Belief - Protest with weapons"
label var belief_9 "Belief - Curse in face"
label var belief_10 "Belief - Send threats"
label var belief_11 "Belief - Share address"
label var belief_12 "Belief - Share location"
label var belief_13 "Belief - Shout out"
label var belief_14 "Belief - Block street"
label var belief_15 "Belief - Heckle event"
label var belief_16 "Belief - Write letter"
label var belief_17 "Belief - Call office"
label var belief_18 "Belief - Write news"
label var belief_19 "Belief - Donate money"
label var belief_20 "Belief - Signs supporting"
label var belief_21 "Belief - Signs opposing"
label var belief_22 "Belief - Campaign"

label var elect_1 "Elect - Kill"
label var elect_2 "Elect - Hit with car"
label var elect_3 "Elect - Throw rocks"
label var elect_4 "Elect - Punch face"
label var elect_5 "Elect - Spray mace"
label var elect_6 "Elect - Throw brick"
label var elect_7 "Elect - Throw eggs"
label var elect_8 "Elect - Protest with weapons"
label var elect_9 "Elect - Curse in face"
label var elect_10 "Elect - Send threats"
label var elect_11 "Elect - Share address"
label var elect_12 "Elect - Share location"
label var elect_13 "Elect - Shout out"
label var elect_14 "Elect - Block street"
label var elect_15 "Elect - Heckle event"
label var elect_16 "Elect - Write letter"
label var elect_17 "Elect - Call office"
label var elect_18 "Elect - Write news"
label var elect_19 "Elect - Donate money"
label var elect_20 "Elect - Signs supporting"
label var elect_21 "Elect - Signs opposing"
label var elect_22 "Elect - Campaign"

label var illegal_1 "Illegal - Kill"
label var illegal_2 "Illegal - Hit with car"
label var illegal_3 "Illegal - Throw rocks"
label var illegal_4 "Illegal - Punch face"
label var illegal_5 "Illegal - Spray mace"
label var illegal_6 "Illegal - Throw brick"
label var illegal_7 "Illegal - Throw eggs"
label var illegal_8 "Illegal - Protest with weapons"
label var illegal_9 "Illegal - Curse in face"
label var illegal_10 "Illegal - Send threats"
label var illegal_11 "Illegal - Share address"
label var illegal_12 "Illegal - Share location"
label var illegal_13 "Illegal - Shout out"
label var illegal_14 "Illegal - Block street"
label var illegal_15 "Illegal - Heckle event"
label var illegal_16 "Illegal - Write letter"
label var illegal_17 "Illegal - Call office"
label var illegal_18 "Illegal - Write news"
label var illegal_19 "Illegal - Donate money"
label var illegal_20 "Illegal - Signs supporting"
label var illegal_21 "Illegal - Signs opposing"
label var illegal_22 "Illegal - Campaign"


recode accept* (1=3) (2=2) (3=1) (4=0)
recode harm* (1=3) (2=2) (3=1) (4=0)
recode fear* (1=3) (2=2) (3=1) (4=0)
recode belief* (1=3) (2=2) (3=1) (4=0)
recode elect* (1=3) (2=2) (3=1) (4=0)
recode illegal* (4=3) (3=2) (2=1) (1=0)

*means
sum accept* harm* fear* belief* elect* illegal*

*create scales of best sets of items - harm
gen best5harm_harm=(harm_1+harm_2+harm_4+harm_3+harm_5)/5
gen best5harm_fear=(fear_1+fear_2+fear_4+fear_3+fear_5)/5
gen best5harm_belief=(belief_1+belief_2+belief_4+belief_3+belief_5)/5
gen best5harm_elect=(elect_1+elect_2+elect_4+elect_3+elect_5)/5

*create scales of best sets of items - aggressive
gen best6fear_harm=(harm_10+harm_8+harm_13+harm_11+harm_9+harm_12)/6
gen best6fear_fear=(fear_10+fear_8+fear_13+fear_11+fear_9+fear_12)/6
gen best6fear_belief=(belief_10+belief_8+belief_13+belief_11+belief_9+belief_12)/6
gen best6fear_elect=(elect_10+elect_8+elect_13+elect_11+elect_9+elect_12)/6

*create scales of best sets of items - conventional
egen convent_harm=rowmean(harm_16-harm_22)
egen convent_fear=rowmean(fear_16-fear_22)
egen convent_belief=rowmean(belief_16-belief_22)
egen convent_elect=rowmean(elect_16-elect_22)

*violence causes greatest harm
ttest best5harm_harm=best6fear_harm
ttest best5harm_harm=convent_harm

*violence causes more fear
ttest best5harm_fear=best6fear_fear
ttest best5harm_fear=convent_fear

*aggressive causes more fear than conventional
ttest best6fear_fear=convent_fear

*conventional actions cause more belief change
ttest convent_belief=best5harm_belief
ttest convent_belief=best6fear_belief

*conventional actions cause more electoral threat
ttest convent_elect=best5harm_elect
ttest convent_elect=best6fear_elect


** figure 1

gen harm_means=.
gen harm_lb=.
gen harm_ub=.
gen action=_n
replace action=. if _n>3

ci means best5harm_harm 
replace harm_means=r(mean) in 1
replace harm_lb=r(lb) in 1
replace harm_ub=r(ub) in 1

ci means best6fear_harm 
replace harm_means=r(mean) in 2
replace harm_lb=r(lb) in 2
replace harm_ub=r(ub) in 2

ci means convent_harm 
replace harm_means=r(mean) in 3
replace harm_lb=r(lb) in 3
replace harm_ub=r(ub) in 3

graph twoway (bar harm_means action if action==1)(bar harm_means action if action==2) (bar harm_means action if action==3) (rcap harm_ub harm_lb action, col(black)), legend(off) xlab(1 "Violent" 2 "Aggressive" 3 "Conventional") ylab(0(.5)2.5) xtitle("") subtitle("Physical Harm") saving(fig1_harm.gph, replace)

gen fear_means=.
gen fear_lb=.
gen fear_ub=.

ci means best5harm_fear 
replace fear_means=r(mean) in 1
replace fear_lb=r(lb) in 1
replace fear_ub=r(ub) in 1

ci means best6fear_fear 
replace fear_means=r(mean) in 2
replace fear_lb=r(lb) in 2
replace fear_ub=r(ub) in 2

ci means convent_fear 
replace fear_means=r(mean) in 3
replace fear_lb=r(lb) in 3
replace fear_ub=r(ub) in 3

graph twoway (bar fear_means action if action==1)(bar fear_means action if action==2) (bar fear_means action if action==3) (rcap fear_ub fear_lb action, col(black)), legend(off) xlab(1 "Violent" 2 "Aggressive" 3 "Conventional") ylab(0(.5)2.5) xtitle("") subtitle("Fear of Harm") saving(fig1_fear.gph, replace)

gen belief_means=.
gen belief_lb=.
gen belief_ub=.

ci means best5harm_belief 
replace belief_means=r(mean) in 1
replace belief_lb=r(lb) in 1
replace belief_ub=r(ub) in 1

ci means best6fear_belief 
replace belief_means=r(mean) in 2
replace belief_lb=r(lb) in 2
replace belief_ub=r(ub) in 2

ci means convent_belief 
replace belief_means=r(mean) in 3
replace belief_lb=r(lb) in 3
replace belief_ub=r(ub) in 3

graph twoway (bar belief_means action if action==1)(bar belief_means action if action==2) (bar belief_means action if action==3) (rcap belief_ub belief_lb action, col(black)), legend(off) xlab(1 "Violent" 2 "Aggressive" 3 "Conventional") ylab(0(.5)2.5) xtitle("") subtitle("Change Beliefs") saving(fig1_belief.gph, replace)

gen elect_means=.
gen elect_lb=.
gen elect_ub=.

ci means best5harm_elect 
replace elect_means=r(mean) in 1
replace elect_lb=r(lb) in 1
replace elect_ub=r(ub) in 1

ci means best6fear_elect 
replace elect_means=r(mean) in 2
replace elect_lb=r(lb) in 2
replace elect_ub=r(ub) in 2

ci means convent_elect 
replace elect_means=r(mean) in 3
replace elect_lb=r(lb) in 3
replace elect_ub=r(ub) in 3

graph twoway (bar elect_means action if action==1)(bar elect_means action if action==2) (bar elect_means action if action==3) (rcap elect_ub elect_lb action, col(black)), legend(off) xlab(1 "Violent" 2 "Aggressive" 3 "Conventional") ylab(0(.5)2.5) xtitle("") subtitle("Electoral Concern") saving(fig1_elect.gph, replace)

graph combine fig1_harm.gph fig1_fear.gph fig1_belief.gph fig1_elect.gph



*factor structure

factor accept*, ml factors(2)
rotate, promax

factor harm*, ml factors(2)
rotate, promax

factor fear*, ml factors(2)
rotate, promax

factor belief*, ml factors(2)
rotate, promax

factor elect*, ml factors(2)
rotate, promax

factor illegal*, ml factors(2)
rotate, promax


